﻿from System.IO import Path
import clr
import sys

# load an assembly from the samples bin directory
sys.path.Add(Path.GetFullPath(r"bin"))
clr.AddReferenceToFileAndPath("Eswat.Samples.SampleComponentLibrary")

# import test types
from Eswat.Samples.SampleComponentLibrary import SampleComponent
from Eswat.Services.WebDriver import WebBrowserType

# alias test services
verify = eswatTest.Services.Verify
web = eswatTest.Services.WebDriver

# test a sample .NET component
comp = SampleComponent()
comp.Title = "hello component world!"
verify.AreEqual("hello component world!", comp.Title, "sample component title should match")
comp.Str = "test"
# -------------------------------------------------------------
# test WebDriver test service
# -------------------------------------------------------------

web.Open(WebBrowserType.IE)

nav = web.Navigate()

nav.GoToUrl("http://localhost:61614/Auth/SignOut")

verify.AreEqual("Mileage Stats | Know where your gas takes you", web.Title, "Silk landing page title should match")

web.Quit()

# -------------------------------------------------------------
# test NUnit test service
# -------------------------------------------------------------

verify.True(True)
verify.True(True, "True(True) should succeed")
verify.True(True, "True({0}) should succeed", "True")
verify.True(False, "True(False) should fail")

verify.IsTrue(True)
verify.IsTrue(True, "IsTrue(True) should succeed")
verify.IsTrue(True, "IsTrue({0}) should succeed", "True")
verify.IsTrue(False, "IsTrue(False) should fail")

verify.False(False)
verify.False(False, "False(False) should succeed")
verify.False(False, "False({0}) should succeed", "False")
verify.False(True, "False(True) should fail")

verify.IsFalse(False)
verify.IsFalse(False, "IsFalse(False) should succeed")
verify.IsFalse(False, "IsFalse({0}) should succeed", "False")
verify.IsFalse(True, "IsFalse(True) should fail")

# bool
verify.AreEqual(True, True)
verify.AreEqual(True, True, "AreEqual(True, True) should succeed")
verify.AreEqual(True, True, "AreEqual({0}) should succeed", "True, True")
verify.AreEqual(True, False, "AreEqual(True, False) should fail")

# float -> passed to .NET as Double
verify.AreEqual(0.0, 0.0)
verify.AreEqual(0.0, 0.0, "AreEqual(0.0, 0.0) should succeed")
verify.AreEqual(0.0, 0.0, "AreEqual({0}) should succeed", "0.0, 0.0")
verify.AreEqual(0.0, 0.1, "AreEqual(0.0, 0.1) should fail")

None